package com.liao.service.impl;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.liao.bean.Count;
import com.liao.bean.result.Msg;
import com.liao.bean.result.PageResult;
import com.liao.dao.CountDao;
import com.liao.service.CountService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class CountServiceImpl implements CountService {

    @Autowired
    private CountDao countDao;

    @Override
    public PageResult<Count> queryCountListByPage(Integer currentPage, Integer pageSize, String orderId) throws Exception {
        PageHelper.startPage(currentPage,pageSize);
        //查询所有菜单
        List<Count> countList = countDao.selectCountListLikeCountName(orderId);
        PageInfo<Count> pageInfo = new PageInfo<>(countList);
        return new PageResult<>(0, Msg.MEMBER_QUERY_SUCCESS,pageInfo.getTotal(),pageInfo.getList());
    }

    @Override
    public void addCount(Count count) throws Exception {
        countDao.addCount(count);
    }

    @Override
    public void editCount(Count count) throws Exception {
        countDao.updateCount(count);
    }

    @Override
    public void deleteCount(String ocid) throws Exception {
        countDao.deleteCount(ocid);
    }

}
